/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author itachiu
 */
@Entity
@Table(name = "appointment")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Appointment.findAll", query = "SELECT a FROM Appointment a"),
    @NamedQuery(name = "Appointment.findByIdAPPOINTMENT", query = "SELECT a FROM Appointment a WHERE a.appointmentPK.idAPPOINTMENT = :idAPPOINTMENT"),
    @NamedQuery(name = "Appointment.findByDateApp", query = "SELECT a FROM Appointment a WHERE a.dateApp = :dateApp"),
    @NamedQuery(name = "Appointment.findByNotes", query = "SELECT a FROM Appointment a WHERE a.notes = :notes"),
    @NamedQuery(name = "Appointment.findByMEDICALRECORDidMEDICALRECORD", query = "SELECT a FROM Appointment a WHERE a.appointmentPK.mEDICALRECORDidMEDICALRECORD = :mEDICALRECORDidMEDICALRECORD")})
public class Appointment implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AppointmentPK appointmentPK;
    @Column(name = "DATE_APP")
    @Temporal(TemporalType.DATE)
    private Date dateApp;
    @Column(name = "NOTES")
    private String notes;
    @JoinColumn(name = "MEDICAL_RECORD_idMEDICAL_RECORD", referencedColumnName = "idMEDICAL_RECORD", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private MedicalRecord medicalRecord;

    public Appointment() {
    }

    public Appointment(AppointmentPK appointmentPK) {
        this.appointmentPK = appointmentPK;
    }

    public Appointment(int idAPPOINTMENT, int mEDICALRECORDidMEDICALRECORD) {
        this.appointmentPK = new AppointmentPK(idAPPOINTMENT, mEDICALRECORDidMEDICALRECORD);
    }

    public AppointmentPK getAppointmentPK() {
        return appointmentPK;
    }

    public void setAppointmentPK(AppointmentPK appointmentPK) {
        this.appointmentPK = appointmentPK;
    }

    public Date getDateApp() {
        return dateApp;
    }

    public void setDateApp(Date dateApp) {
        this.dateApp = dateApp;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public MedicalRecord getMedicalRecord() {
        return medicalRecord;
    }

    public void setMedicalRecord(MedicalRecord medicalRecord) {
        this.medicalRecord = medicalRecord;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (appointmentPK != null ? appointmentPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Appointment)) {
            return false;
        }
        Appointment other = (Appointment) object;
        if ((this.appointmentPK == null && other.appointmentPK != null) || (this.appointmentPK != null && !this.appointmentPK.equals(other.appointmentPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Appointment[ appointmentPK=" + appointmentPK + " ]";
    }
    
}
